package cn.glow.readingcloud.book.config;


import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author Glow
 * @Date 2023-04-11 23:46:45
 * @Description mybatisplus分页、乐观锁配置
 * @Version 1.0
 */
@Configuration
@MapperScan("cn.glow.readingcloud.book.dao")
public class MybatisPlusConfig {
    /**
     * 乐观锁插件
     * 分页插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //配置乐观锁
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        //配置分页
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
